package com.zz.inventory.controller;

import java.util.List;
import java.io.IOException;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.zz.inventory.domain.FranchisePackages;
import com.zz.inventory.service.IFranchisePackagesService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 套餐配置管理Controller
 * 
 * @author zz
 * @date 2025-07-03
 */
@RestController
@RequestMapping("/packages")
public class FranchisePackagesController extends BaseController
{
    @Autowired
    private IFranchisePackagesService franchisePackagesService;
    /**
     * 查询套餐配置管理列表
     */
    @RequiresPermissions("platform:packages:list")
    @GetMapping("/list")
    public TableDataInfo list(FranchisePackages franchisePackages)
    {
        startPage();
        List<FranchisePackages> list = franchisePackagesService.selectFranchisePackagesList(franchisePackages);
        return getDataTable(list);
    }

    /**
     * 导出套餐配置管理列表
     */
    @RequiresPermissions("platform:packages:export")
    @Log(title = "套餐配置管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FranchisePackages franchisePackages)
    {
        List<FranchisePackages> list = franchisePackagesService.selectFranchisePackagesList(franchisePackages);
        ExcelUtil<FranchisePackages> util = new ExcelUtil<FranchisePackages>(FranchisePackages.class);
        util.exportExcel(response, list, "套餐配置管理数据");
    }

    /**
     * 获取套餐配置管理详细信息
     */
    @RequiresPermissions("platform:packages:query")
    @GetMapping(value = "/{packageId}")
    public AjaxResult getInfo(@PathVariable("packageId") Long packageId)
    {
        return success(franchisePackagesService.selectFranchisePackagesByPackageId(packageId));
    }

    /**
     * 新增套餐配置管理
     */
    @RequiresPermissions("platform:packages:add")
    @Log(title = "套餐配置管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FranchisePackages franchisePackages)
    {
        return toAjax(franchisePackagesService.insertFranchisePackages(franchisePackages));
    }

    /**
     * 修改套餐配置管理
     */
    @RequiresPermissions("platform:packages:edit")
    @Log(title = "套餐配置管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FranchisePackages franchisePackages)
    {
        return toAjax(franchisePackagesService.updateFranchisePackages(franchisePackages));
    }

    /**
     * 删除套餐配置管理
     */
    @RequiresPermissions("platform:packages:remove")
    @Log(title = "套餐配置管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{packageIds}")
    public AjaxResult remove(@PathVariable Long[] packageIds)
    {
        return toAjax(franchisePackagesService.deleteFranchisePackagesByPackageIds(packageIds));
    }
}
